package com.wc.算法提高课.C第三章_图论.无向图的双连通分量.电力;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/10/22 16:13
 * @description https://www.acwing.com/problem/content/1185/
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 10010, M = 30010;
    static int[] h = new int[N], e = new int[M], ne = new int[M];
    static int[] dfn = new int[N], low = new int[N];
    static int idx = 1, timestamp = 0;
    static int n, m, ans = 0, root = 0;

    public static void main(String[] args) {
        while (sc.hasNext()) {
            n = sc.nextInt();
            m = sc.nextInt();
            if (n == 0 && m == 0) break;
            Arrays.fill(h, 0, n, 0);
            Arrays.fill(dfn, 0, n, 0);
            idx = 1;
            while (m-- > 0) {
                int a = sc.nextInt(), b = sc.nextInt();
                add(a, b);
                add(b, a);
            }
            // 单个连通块中边连通的最大值
            ans = 0;
            // 连通快的数量
            int cnt = 0;
            timestamp = 0;
            for (root = 0; root < n; root++) {
                if (dfn[root] == 0) {
                    cnt++;
                    tarjan(root);
                }
            }
            out.println(ans + cnt - 1);
        }
        out.flush();
    }

    static void tarjan(int u) {
        dfn[u] = low[u] = ++timestamp;
        // u这个点连接的连通块的数量
        int cnt = 0;
        for (int i = h[u]; i > 0; i = ne[i]) {
            int j = e[i];
            if (dfn[j] == 0) {
                tarjan(j);
                low[u] = Math.min(low[u], low[j]);
                if (dfn[u] <= low[j]) cnt++;
            } else low[u] = Math.min(low[u], dfn[j]);
        }
        // 还有父节点那一坨
        if (u != root) cnt++;
        ans = Math.max(ans, cnt);
    }

    static void add(int a, int b) {
        e[idx] = b;
        ne[idx] = h[a];
        h[a] = idx++;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
